/*#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
void rotate(long long a[][11], int n)
{
	int i, j,t;
	long long b[][11] = { 0 };
	
	for (i = 1,t=n; t>=0,i <= n;t--, i++)
		for (j =1; j <= n; j++)
		{
			b[j][t] = a[i][j];
	    }

	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
		{
			
			a[i][j] = b[i][j];
		}

}
int main()
{
	long long x[][11] = { 0 };
	long long y[][11] = { 0 };
	int n,i,j,k,m;
	while (scanf("%d", &n) != EOF)
	{
		scanf("%d", &k);
		for (i = 1; i <= n; i++)
			for (j = 1; j <= n; j++)
			{
				scanf("%lld", &x[i][j]);
				y[i][j] = x[i][j];
			}
		for (m = 1; m <= k; m++)
		{
			rotate(y,n);
			for (i = 1; i <= n; i++)
				for (j = 1; j <= n; j++)
					x[i][j] += y[i][j];
		}
		for (i = 1; i <= n; i++)
		{
			for (j = 1; j <= n; j++)
			{
				printf("%lld ", x[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}*/